package com.example.a79273.shandianban.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;

import com.example.a79273.shandianban.R;

/**
 * 加载对话框
 */
public class MyDialogFragment extends DialogFragment {

    private ImageView anim;
    private RotateAnimation rotateAnimation;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(STYLE_NO_TITLE, R.style.dialog);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceSate) {
        View view = inflater.inflate(R.layout.fragment_dialog, container, false);
        anim = (ImageView) view.findViewById(R.id.iv_dialog_animation);
        rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        rotateAnimation.setDuration(1000);
        rotateAnimation.setRepeatCount(Animation.INFINITE);
        return view;
    }

    @Override
    public void onStart() {
        super.onStart();
        anim.startAnimation(rotateAnimation);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
    }

}
